#pragma once
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
//#include "opencv.hpp"
#include "svm.h"
#include "CTruthDataPoint.h"
#include "DataPointManager.h"
#include "DataPoint.h"
#include "ImgTxtWriter.h"
#include "FeatureExtractorBase.h"
#include "SVMClassificationModule.h"
#include "ObjectExtractor.h"
#include "RecognizerObjects.h"
class CRecognizerModule
{
public:
	CRecognizerModule(void);
	virtual ~CRecognizerModule(void);
	// Load the SVM
	bool LoadSVM( std::string path, std::string fname );

	// Draw the bounding box around the objects that are detected
	IplImage * DrawDetectedObjects( IplImage * img ); 

	// Take and image, extract out the objects and write to file
	// this is useful for building up a training data set. 
	void ExtractDetectedObjects( IplImage * img, std::string path, std::string fname, std::string ext = ".jpg");

	// Get the feature extractor
	CFeatureExtractorBase * GetFeatureExtractor( void );

	// Set the feature extractor 
	void SetFeatureExtractor( CFeatureExtractorBase* featExtractor );

	// return the recognized objects in the frame
	SRecObjVec RecognizeFrame(  IplImage * img );

	// Get the object extractor to set the thresholds and such. 
	CObjectExtractor& GetObjectExtractor( void ); 
	
	// write the bounding box and name of the objects to the frame. 
	IplImage* WriteObjectsToFrame( IplImage * input, SRecObjVec& objects ); 
	
	// Get the thing that writes the text. 
	CImgTxtWriter& GetTextWritter( void );

	void SetThreshold( int threshold ); 
	int GetThreshold( void ); 	 
	
	void SetExtractorParams( int maxSz, int minSz, int minWH ); 

protected:
 	CObjectExtractor m_extractor; // gets the objects in the frame
	CFeatureExtractorBase* m_featureExtractor; // gets the feature set from each object. 
	CSVMClassificationModule m_classifier;
	CImgTxtWriter m_txtWrite;
	int m_index; 
};
